{include file="public/header" /}

<style>
    body{
        background: #FFF;
    }

</style>

<div class="page">
    <table class="ds-default-table order">
        <tr>
            <th>派单</th>
        </tr>

            <table class="ds-default-table">
                <!--店主账号-->
                <!--状态-->
                <input type="hidden" id="order_id" name="order_id" value={$order_id} >
                <input type="hidden" id="now_merids" name="now_merids" value={$now_merids} >
                <tr class="noborder" style="background: rgb(255, 255, 255);">
                    <td class="w120"><label class="" for="">下单预定时间:</label></td>
                    <td class="vatop tips">{$order.appointment_time}</td>
                </tr>

                <tr class="noborder" style="background: rgb(255, 255, 255);">
                    <td class="w120"><label class="" for="">客户姓名:</label></td>
                    <td class="vatop tips">{$address.address_realname}</td>
                </tr>

                <tr class="noborder" style="background: rgb(255, 255, 255);">
                    <td class="w120"><label class="" for="">客户电话:</label></td>
                    <td class="vatop tips">{$address.address_tel_phone}</td>
                </tr>

                <tr class="noborder" style="background: rgb(255, 255, 255);">
                    <td class="w120"><label class="" for="">客户地址:</label></td>
                    <td class="vatop tips">{$address.area_info}&nbsp;{$address.address_detail}&nbsp;</td>
                </tr>

                <tr class="noborder" style="background: rgb(255, 255, 255);">
                    <td>
                        <a href="javascript:void(0);" onclick="
                       edit_band_goods({$order_id});" class="btn">选择服务人员</a>
                    </td>
                    <td>
                        <a href="javascript:void(0);" class="btn" id="btn2">确认派单</a>
                    </td>
                    
                </tr>
                <script>
                    function edit_band_goods(order_id) {
                        _uri = ADMINSITEURL+"/Service/send_service_person?oid=" + order_id;
                        dsLayerOpen(_uri,'选择服务人员','900px','700px');
                    }
                </script>

            </table>
    </table>
    <table class="ds-default-table order">
    <tr>
        <th>派单列表</th>
    </tr>
    <tr>
        <td><table class="ds-default-table goods ">
            <tbody>
            <tr>
                <th class="align-center">派单id</th>
                <th class="align-center">技术工姓名</th>
                <th class="align-center">联系电话</th>
                <th class="align-center">派单状态</th>
                <th class="align-center">操作人</th>
                <th class="align-center">创建日期</th>
                <th class="align-center">操作</th>
            </tr>
            {foreach name="$order_mechanics" item="order_mechanic"}
            <tr>
                <td class="w5 align-center"><p>{$order_mechanic.id}</p></td>
                <td class="w20 align-center"><p>{$order_mechanic.name}</p></td>
                <td class="w20 align-center"><p>{$order_mechanic.phone}</p></td>
                <td class="w20 align-center"><span class="red_common">{$status[$order_mechanic.status]}</span></td>
                <td class="w20 align-center"><p>{$order_mechanic.admin_name}</p></td>
                <td class="w180 align-center"><span class="red_common">{$order_mechanic.create_at|date="Y-m-d H:i:s",###}</span></td>
                <td class="w20 align-center">
                    <a href="javascript:dsLayerConfirm('{:url('Service/del_mechanic',['id'=>$order_mechanic.id])}','您确定取消派单给他吗？')" class="dsui-btn-del"><i class="iconfont"></i>删除</a>
                </td>
            </tr>
            {/foreach}
            </tbody>
        </table>
        </td>
    </tr>
    </table>
</div>
<script>
    $(document).on('click', '#btn2', function() {
        var order_id = $("#order_id").val();
        var now_merids = $("#now_merids").val();
        if(now_merids == ''){
            layer.msg('请选择服务人员');
            return false;
        }
        var obj = $(this);
        $.ajax({
            type: 'POST',
            url: "{:url('service/send_service_notice')}",
            cache: false,
            data: {order_id:order_id,now_merids:now_merids},
            dataType: 'json',
            success: function (data) {
                if(data.code==0){
                    layer.msg(data.msg);
                    location.href=data.url;return false;
                }else{
                    layer.msg(data.msg);
                    location.href=data.url;return false;

                }
            }
        });return false;
    });

    /**
     * Layer 通用ifram弹出窗口
     */
    function dsLayerOpen(url, title,width,height) {
        if (!width) width = '900px';
        if (!height) height = '500px';
        layer.open({
            type: 2,
            title: title,
            area: [width,height],
            fixed: false, //不固定
            maxmin: true,
            content: url
        });
    }
</script>